!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! calculate function coefficients for given nozzle wall function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! wall function is y=aw+bw*x+cw*x^2
! slope of wall is dy/dx=tan(theta)=bw+2*cw*x
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! nomenclature:
!   aw,bw,cw    wall equation constant
!   da,de       slope at point a and e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! warning:
!   all angle in rad, not degree
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine Wall2c()
   use VariableDef
   implicit none
   ! given variables
   ! real*8::yt,rtd,thetaa,xe,thetae
   ! teporary variables
   real*8::da,de
   ! calculate variables
   ! real*8::xa,ya,aw,bw,cw,ye
! attachment point
   xa=rtd*sin(thetaa)
   ya=yt+rtd*(1-cos(thetaa))
   
   da=tan(thetaa)
   de=tan(thetae)
   
   aw=((da+de)*xa**2-2*xa*xe*da+2*ya*(xe-xa))/(2*(xe-xa))
   bw=(xe*da-xa*de)/(xe-xa)
   cw=(de-da)/(2*(xe-xa))
   
   ye=aw+bw*xe+cw*xe**2   ! exit lip point radical location
end subroutine Wall2c
